
ac.game:event '单位-吞噬装备'(function(_,unit,item)
    local player = unit.owner
    local hero = player.hero
    local lock = player:get_data('不可吞噬') or {}
    local list = player:get_data('装备吞噬列表') or {}
    if not hero then
        return false
    end
    if lock[item.name] then
        return false
    end
    lock[item.name] = true
    show_item_tip(player,item,'吞噬')
    table.insert(list,item)
    --table.sort(list,function(a,b) return a.index<b.index end)
    item:remove()
    player:set_data('不可吞噬', lock)
    player:set_data('装备吞噬列表', list)
    hero:notify('单位-添加物品属性',hero,item)
    hero:notify('单位-吞噬物品完成',hero,item)

end)


ac.item('初级吞噬丹'){
    item_type = "charged",
    auto_merge = true,
    targettype = "物体",
    allowtype = '物品',
    count = 1,
    range = 9999,
    cool = 0.2,
    lum = 500,
    rate = 100,
    tip = [[吞噬初级装备|n|n吞噬后额外获得'rate'%装备属性]],
    on_use = function(self, item)
        local hero = self.owner
        local player = hero.owner
        if item['无法吞噬'] then
            self:set_count(self:get_count())
            ac.console:error(player, "该装备无法吞噬")
            return
        end
        if item.item_level~=item.max_level then
            self:set_count(self:get_count())
            ac.console:error(player, "只能对满级装备使用")
            return
        end
        if hero:dispatch('单位-吞噬装备', hero, item)==false then
            self:set_count(self:get_count())
            ac.console:error(player, "该装备已被吞噬")
        end
    end
}

ac.item('高级吞噬丹'){
    temp = '初级吞噬丹',
    lum = 1000,
    rate = 200,
    tip = [[吞噬高级装备|n|n吞噬后额外获得200%装备属性]],
}

ac.item('超级吞噬丹'){
    temp = '初级吞噬丹',
    lum = 2000,
    rate = 400,
    tip = [[吞噬高级装备|n|n吞噬后额外获得400%装备属性]],
}
